package com.fire.web.modules.all.utils;

import com.fire.common.utils.StringUtils;
import com.fire.web.modules.all.controller.ProprietorController;
import com.fire.web.security.shiro.filter.authc.Oauth2Token;
import com.fire.web.utils.JWTHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TokenUtil {
	private static final Logger LOGGER = LoggerFactory.getLogger(TokenUtil.class);
	private static final String DEFAULT_ACCESS_TOKEN_PARAM = "access_token";
	public static String getToken(HttpServletRequest request, HttpServletResponse response) {
		String token = request.getHeader(DEFAULT_ACCESS_TOKEN_PARAM);
		LOGGER.info("httpServletRequest.getHeader方法获取的token："+token);
		if (StringUtils.isEmpty(token)){
			token = request.getParameter(DEFAULT_ACCESS_TOKEN_PARAM);
			LOGGER.info("httpServletRequest.getParameter方法获取的token："+token);
		}
		if(StringUtils.isNotBlank(token)){
			return token;
		}
		return null;
	}
}
